<template>
  <MainLayout
    :role-name="'系统管理员'"
    :system-title="'质量管理系统'"
    :base-route-path= loginInfo.redirectUrl
    :user-name=userInfo.name
  >
    <template #menu-items>
      <el-menu-item index="/admin/home">
        <el-icon style="color: #fff;"><HomeFilled /></el-icon>
        <span style="color: #fff;">首页</span>
      </el-menu-item>
      <el-menu-item index="/admin/quality-data">
        <el-icon style="color: #fff;"><DataAnalysis /></el-icon>
        <span style="color: #fff;">质量数据管理</span>
      </el-menu-item>
      <el-menu-item index="/admin/user-management">
        <el-icon style="color: #fff;"><User /></el-icon>
        <span style="color: #fff;">人员管理</span>
      </el-menu-item>
      <!-- <el-menu-item index="/admin/permission-management">
        <el-icon style="color: #fff;"><Key /></el-icon>
        <span style="color: #fff;">权限管理</span>
      </el-menu-item> -->
    </template>
  </MainLayout>
</template>

<script setup lang="ts">
import MainLayout from '@/components/layout/MainLayout.vue'
import {
  HomeFilled,
  DataAnalysis,
  User,
  Key
} from '@element-plus/icons-vue'
import { userInfoStore } from '@/stores/userInfo';
import { loginInfoStore } from '@/stores/loginInfo';
import { getUserInfoService } from '@/api/UsersApi.ts';
import { ElMessage } from 'element-plus';

const userInfo = userInfoStore();
const loginInfo = loginInfoStore();

const getUserInfo = async () =>{
  let result = await getUserInfoService();
  //将用户信息保存到仓库中
  userInfo.setUserInfo(result.data);
}

//当打开页面时获取当前用户基本信息
getUserInfo();

</script>